package com.paopao.employee.mapper;

import com.paopao.domain.EmployeeBean;
import com.paopao.mapper.MySqlprovider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EmployeeMapper {
    @Insert("insert into swans_employee_info(name, employee_no, sex, age, position, post_level, create_time, update_time, status) " +
            "values(#{name}, #{employeeNo}, #{sex}, #{age}, #{position}, #{postLevel}, #{creatTime}, #{updateTime}, #{status})")
    public Integer addEmployee(EmployeeBean bean);

    @Delete("delete from swans_employee_info where id = #{id}")
    public Integer deleteEmployee(int id);

    @Update("update swans_employee_info name=#{name}, employee_no#{employeeNo}, age#{age}, sex=#{sex}, position#{position}, post_level#{postLevel}, " +
            "create_time#{createTime}, update_time#{updateTime}, status#{status} where id = #{id}")
    public Integer editEmployee(@Param("bean") EmployeeBean bean);

    @Select("select id, name, sex, employee_no as employeeNo, age, position, post_level as postLevel, create_time as creatTime, update_time as updateTime, status from swans_employee_info where id = #{id}")
    @Results({ @Result(column = "creatTime", property = "creatTime",typeHandler=com.paopao.domain.CalendarTypeHandler.class),
            @Result(column = "updateTime", property = "updateTime",typeHandler=com.paopao.domain.CalendarTypeHandler.class) })
    public EmployeeBean selectEmployeeByid(int id);

    @SelectProvider(type = MySqlprovider.class, method = "getListSql")
    @Results({ @Result(column = "creatTime", property = "creatTime",typeHandler=com.paopao.domain.CalendarTypeHandler.class),
            @Result(column = "updateTime", property = "updateTime",typeHandler=com.paopao.domain.CalendarTypeHandler.class) })
    public List<EmployeeBean> getList(@Param("searchBean") EmployeeBean employeeBean);
}
